import { get, post, put, del } from '@/utils/request'

export const addRole = async (data:any) => {
    try {
        const response = await post<any>('/role/add', data);
        return response;
    } catch (error) {
    }
};

export const updateRole = async (data:any) => {
    try {
        const response = await post<any>('/role/update', data);
        return response;
    } catch (error) {
    }
};

export const deleteRole = async (data:any) => {
    try {
        const response = await post<any>('/role/delete', data);
        return response;
    } catch (error) {
    }
};

// 获取全量菜单，并设置选中状态
export const pageRole = async (data:any) => {
    try {
        const response = await post<any>('/role/page', data);
        return response;
    } catch (error) {
    }
};

// 只获取被选中菜单的id集合
export const getMenuListByRoleId = async (data:any) => {
    try {
        const response = await get<any>('/roleMenu/getMenuListByRoleId', data);
        return response;
    } catch (error) {
    }
};

export const getSelectedMenuListByRoleId = async (data:any) => {
    try {
        const response = await get<any>('/roleMenu/getSelectedMenuListByRoleId', data);
        return response;
    } catch (error) {
    }
};

export const roleMenuSetting = async (data:any) => {
    try {
        const response = await post<any>('/roleMenu/roleMenuSetting', data);
        return response;
    } catch (error) {
    }
};


export interface Role {
    id: number,
    name: string,
    enName: string,
}
export interface QueryParams {
    pageNum: number,
    pageSize: number,
    name: string,
    enName: string,
}
export interface RoleAddRequest {
    id: number | null,
    name: string,
    enName: string,
}

export interface MenuListRequest {
    roleId: number,
}
export interface UserRoleRequest {
    userId: number | null,
    roleIdList: number[],
}